﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using model;
using Bll;

public partial class edita : System.Web.UI.Page
{
    ApplicationBll bll = new ApplicationBll();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int ano = Convert.ToInt32(Request.Params["ano"]);
            model.Application app = bll.GetSingle(ano);
            txtPosition.Text = app.Position;
            txtPlace.Text = app.Place;
            txtNumber.Text = app.Number;
            txtSalary.Text = app.Salary;
            txtConn.Text = app.Conn;
            txtAintro.Text = app.Aintro;
            ViewState["ano"] = ano;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        model.Application app = bll.GetSingle(Convert.ToInt32(ViewState["ano"]));
        app.Ano = Convert.ToInt32(ViewState["ano"]);
        app.Position = txtPosition.Text;
        app.Place = txtPlace.Text;
        app.Number = txtNumber.Text;
        app.Salary = txtSalary.Text;
        app.Conn = txtConn.Text;
        app.Aintro = txtAintro.Text;
        try
        {
            bll.Update(app);
            if (Session["usergroup"].ToString() != "enterprise")
            {
                Response.Write("<script>alert('修改成功！');location.href='Applictioncfg.aspx';</script>");
            }
            Response.Write("<script>alert('修改成功！');location.href='EA.aspx';</script>");
        }
        catch (Exception ex)
        {
            string js = "<script>alert('" + ex.Message + "');</script>";
            Response.Write(js);
        }
    }
}